﻿var PublishCtrl = (function () {
	var that;
	var obj = function () {
		that = this;
	};

	obj.prototype = {
		ctrl: function ($scope, $http,$timeout) {
			that.$scope = $scope;
			that.$http = $http;
			that.$timeout = $timeout;

			that.$scope.showImage = [];

			that.$scope.redirect = Util.navChange;
			that.$scope.openCapture = that.openCapture;
			that.$scope.openPhotoGallery = that.openPhotoGallery;
			that.initScreening();

			that.first();
		},

		first: function () {
			var div = document.createElement("div");
			div.className = "firstTishi";
			div.addEventListener("click", function () {
				document.body.removeChild(this);
			}, false);
			document.body.appendChild(div);
		},

		initScreening: function () {
			that.$scope.screeningData = Util.getScreeningData();
		},

		openCapture:function(){
			that.$scope.photograph = false;
			CommonUtil.openCapture(function(path){
				$('.upload_image')[0].src = "data:image/jpeg;base64," + path;
				that.$timeout(function(){
					that.$scope.showImage[0] = true;	
				})
				
			})
		},

		openPhotoGallery:function(){
			that.$scope.photograph = false;
			CommonUtil.openPhotoGallery(function(path){
				$('.upload_image')[1].src = "data:image/jpeg;base64," + path;
				that.$timeout(function(){
					that.$scope.showImage[1] = true;
				})
			})
		}
	};

	return new obj();
})();